<?php
if (!defined('IN_XLP')) {
    exit('Access Denied');
}
$Document = array(
    'pageid' => 'village-index', //页面标示
    'pagename' => '小区列表', //当前页面名称
    'mycss' => array(), //加载的css样式表
    'myjs' => array(), //加载的js脚本
	'footerjs'=>array('content/jquery.smoothConfirm'),
    'head' => true, //加载头部文件
);
$page_num = isset($_GET['p']) ? intval($_GET['p']) : 1;
include getTpl('header', 'public');
?>
<!--顶部导航 开始-->
<?php include getTpl('top', 'public');?>
<!--顶部导航 结束-->
<!--左侧菜单 开始-->
<?php include getTpl('nav', 'public');?>
<!--左侧菜单 结束-->
<!--主体 开始-->
<!-- content -->
  <section id="content">
    <!-- main padder --> 
    <section class="main padder">
        <div class="clearfix"> 
			<h4><i class="fa fa-table"></i><?php echo trim($Document['pagename'],'_');?></h4> 
        </div>
        <div class="row">
			<!-- table 11 -->
			<div class="col-lg-12">
				<section class="panel">
                <div class="panel-body"> 
                    <div class="row text-small"> 
                        <div class="col-sm-8">
                            <a class="btn btn-default" href="<?php echo U('village/add');?>">添加小区</a>
                             <div class="btn-group" style="margin-left:8px">
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('all'=>1));?>">全部</a>
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('is_open'=>1));?>">未开通</a>
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('is_open'=>2));?>">已开通</a>
                             </div>
                             <div class="btn-group" style="margin-left:8px">
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('all'=>1));?>">全部</a>
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('order'=>'count'));?>">入住人数</a>
                             </div>
                             <div class="btn-group" style="margin-left:8px">
                             <?php foreach($stype as $key=>$val){?>
                                 <a class="btn btn-default" href="<?php echo U('village/index',array('type'=>($key+1)));?>"><?php echo $val;?></a>
                              <?php }?>
                             </div>
                        <!---->
                         </div>
                         <div class="col-sm-4">
                             <form action="<?php echo U(ACTION_NAME.'/index');?>" method="get" name="form1" target="_self">
                              <div class="input-group"> 
                               <input type="text" name="q" class="input-sm form-control" placeholder="请输入搜索关键字..." /> 
                               <input name="g" type="hidden" value="<?php echo GROUP_NAME;?>" />
                               <input name="c" type="hidden" value="<?php echo ACTION_NAME;?>" />
                               <input name="m" type="hidden" value="<?php echo MODEL_NAME;?>" />
                               <span class="input-group-btn"> <button class="btn btn-sm btn-white" type="submit">搜索</button> </span> 
                              </div> 
                              </form>
                         </div> 
                    </div> 
      			</div>
					<div class="table-responsive"> 
						<table class="table table-striped b-t text-small"> 
							<thead>
                              <tr>
                                <th align="center">ID</th>
                                <th align="center">城市</th>
                                <th align="center">类型</th>
                                <th align="center">名称</th>
                                <th align="center">搜索名称</th>
                                <th align="center">城区</th>
                                <th align="center">街道</th>
                                <th align="center">社区</th>
                                <th align="center">商圈</th>
                                <th align="center">服务中心</th>
                                <th align="center">入住人数</th>
                                <th align="center">物流配送</th>
                                <th align="center" width="150">操作</th>
                              </tr>
                            </thead>
                            <tbody>
                              <?php
                            if ($rs){
                                foreach($rs as $val){
                            ?>
                              <tr id="list_detail_id_<?php echo $val['vid'];?>">
                              <td><?php echo $val['vid'];?></td>
                                <td><?php echo $val['city_name'];?></td>
                                <td><?php echo $stype[$val['stype']];?></td>
                                <td><?php echo $val['title'];?></td>
                                <td><?php echo $val['ctitle'];?></td>
                                <td><?php echo $val['area_name'];?></td>
                                <td><?php echo $val['street_name'];?></td>
                                <td><?php echo $val['community_name'];?></td>
                                <td><a href="<?php echo U('village/index',array('zone_id'=>$val['zone_id']));?>"><?php echo $val['business_zone_name'];?></a></td>
                                <td><a href="<?php echo U('village/index',array('service_id'=>$val['service_id']));?>"><?php echo $val['service_name'];?></a></td>
                                <td><a href="<?php echo U('member/index',array('village_id'=>$val['vid']));?>"><?php echo $val['count']?$val['count']:0;?></a></td>
                                <td><?php echo $openstatus[$val['is_open']];?></td>
                                <td>
								<div class="btn-group"> 
                                    <button class="btn btn-white btn-xs dropdown-toggle" data-toggle="dropdown">操作<span class="caret"></span></button> 
                                    <ul class="dropdown-menu">
                                    	<li><a rel="pop" href="<?php echo U('village/geturl',array('id'=>$val['vid']));?>">绑定链接</a></li>
                                        <li class="divider"></li>
                                        <li><a href="<?php echo U('village/edit',array('id'=>$val['vid']))."#{$page_num}";?>">编辑</a></li>
                                        <li><a href="javascript:;" rel="<?php echo $val['vid'];?>" class="delete">删除</a></li>
                                    </ul> 
								</div>
                                </td>
                              </tr>
                              <?php
                                }
                            }else{
                              ?>
                              <tr>
                                <td colspan="7" align="center">暂无数据</td>
                              </tr>
                              <?php
                            }
                            ?>
                            </tbody>
						</table> 
					</div> 
					 <footer class="panel-footer"> 
						<div class="row"> 
							<div class="col-sm-12 text-right text-center-sm">
                  <div style="display:inline;position:relative;top:22px;">
                    <input type="number" id="page_num" style="width:50px;margin:0 6px 0 0;"><button onclick="goToPage();">转到</button>
                  </div>
									<?php echo page($total,$p,'',$pageShow,'p');?>
							</div> 
						</div> 
					</footer>
				</section> 
			</div> 
			<!--/ table 11 -->

        </div> 
    </section>
    <!--/ main padder -->  
  </section> 
  <!--/ content --> 
<!--主体 结束-->
<script>
function goToPage() {
  var page = parseInt($('#page_num').val());
  if(isNaN(page) || page<1) {
    return false;
  } else {
    self.location.href= "<?php echo U('content/village/index') ?>"+'?p='+page;
  }
}
$(function(){
	$('.delete').click(function(){
		var id=$(this).attr('rel');
	  $(this).smoothConfirm("确认删除该小区吗？", {
		  ok: function() {
			  Msg.loading();
			  $.post('<?php echo U('village/delete');?>',{"id":id},function(result){
				  Msg.hide();
			    if (result.status==1){
					$("#list_detail_id_"+id).fadeOut();	  
				}else{
					Msg.error(result.info);  
				}
			  },'json');
		  },
		  cancel: function() {
			  return false;
		  }
	  });
	  $("body").click();
	  return false;
	})	
})
</script>
<?php
include getTpl('footer', 'public');
?>